package com.szxy.frontend.portal.controller;

import com.szxy.frontend.portal.service.ItemCategoryService;
import com.szxy.frontend.portal.service.ItemParamItemService;
import com.szxy.frontend.portal.service.ItemService;
import com.szxy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther:zwer
 * @Date:2019/9/11 21:08
 * @Description:com.szxy.frontend.portal.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/frontend/item")
public class ItemController {

    @Autowired
    private ItemService itemService;
    @Autowired
    private ItemCategoryService itemCategoryService;
    @Autowired
    private ItemParamItemService itemParamItemService;

    /**
     * 查找商品基本信息
     * @param itemId  商品 ID
     * @return
     */
    @PostMapping("/selectItemInfo")
    public Result selectItemInfo(Long itemId){
        return this.itemService.selectItemInfo(itemId);
    }

    /**
     * 查询商品描述信息
     * @param itemId
     * @return
     */
    @PostMapping("/selectItemDescByItemId")
    public Result selectItemDescByItemId(Long itemId){
        try {
            return this.itemService.selectItemDescByItemId(itemId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.build(500,"error");
    }

    /**
     * 查询商品规格参数
     * @param itemId 商品 ID
     * @return
     */
    @PostMapping("/selectTbItemParamItemByItemId")
    public Result selectTbItemParamItemByItemId(Long itemId){
        try {
            return this.itemService.selectTbItemParamItemByItemId(itemId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.build(500,"error");
    }
}
